import actionType from "./index";
import UserService from "../model/user/Service"; //用户的接口

let asyncToken = (playload: any) => {
  return async (dispatch: any) => {
    return new Promise(async (resolve, reject) => {
      let { data } = await UserService.querytoken(playload);
      if (data) {
        resolve({
          msg: "登陆成功",
          data,
        });
      } else {
        reject({ msg: "登陆失败", data });
      }
    });
  };
};

let asyncGetlist = (playload: any) => {
  return async (dispatch: any) => {
    return new Promise(async (resolve, reject) => {
      let { data } = await UserService.getuserinfos(playload);
      if (data.code == 1) {
        resolve({
          msg: "成功",
          data,
        });
      } else {
        reject({ msg: "失败", data });
      }
    });
  };
};

export { asyncToken, asyncGetlist };
